package com.xckx.VisioViewer;

import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class ProcessDialog extends JDialog {
  MainFrame mainFrm = null;
  JPanel processPanel = new JPanel();
  XYLayout xYLayout1 = new XYLayout();
  JButton processBtn = new JButton();
  JLabel processLabel = new JLabel();
  JLabel jLabel1 = new JLabel();
  JLabel jLabel2 = new JLabel();

  public ProcessDialog(MainFrame frame, String title, boolean modal) {
    super(frame, title, modal);
    this.mainFrm = frame;
    try {
      jbInit();
      pack();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }

  public ProcessDialog() {
    this(null, "", false);
  }

  private void jbInit() throws Exception {
    Icon waitIco = new ImageIcon(com.xckx.VisioViewer.ProcessDialog.class.getResource("Image/wait.gif"));

    processPanel.setBorder(BorderFactory.createRaisedBevelBorder());
    processPanel.setMaximumSize(new Dimension(350, 191));
    processPanel.setMinimumSize(new Dimension(350, 191));
    processPanel.setLayout(xYLayout1);
    this.setContentPane(processPanel);
    this.setResizable(false);
    this.setTitle(mainFrm.getBundledResource().getString("ProcessDialog_Title"));
    processPanel.setFont(new java.awt.Font("Dialog", 0, 14));
    processPanel.setAlignmentY((float) 0.5);
    processBtn.setFont(new java.awt.Font("Dialog", 0, 14));
    processBtn.setAlignmentX((float) 0.0);
    processBtn.setActionCommand(mainFrm.getBundledResource().getString("OK"));
    processBtn.setText(mainFrm.getBundledResource().getString("Cancel"));
    processBtn.addMouseListener(new processDialog_processBtn_mouseAdapter(this));
    processLabel.setText(mainFrm.getBundledResource().getString("ProcessDialog_Illus"));
    processLabel.setRequestFocusEnabled(true);
    processLabel.setFont(new java.awt.Font("Dialog", 0, 14));
    jLabel2.setPreferredSize(new Dimension(93, 70));
    jLabel2.setIcon(waitIco);
    jLabel2.setText("");
    processPanel.add(processBtn,   new XYConstraints(167, 158, -1, -1));
    processPanel.add(jLabel1,   new XYConstraints(101, 215, 286, 22));
    processPanel.add(processLabel, new XYConstraints(27, 87, 213, -1));
    processPanel.add(jLabel2,  new XYConstraints(264, 70, 101, -1));
    this.setSize(390,240);
  }

  void processBtn_mouseClicked(MouseEvent e) {
    if (mainFrm != null)
      mainFrm.stopThreads();
    this.dispose();
  }


  public void update(Graphics g) {
    super.update(g);
    if (mainFrm != null && mainFrm.ifThreadsStoped())
      this.dispose();
  }

  public void setLabelText(String txt) {
    processLabel.setText(txt);
  }
}

class processDialog_processBtn_mouseAdapter extends java.awt.event.MouseAdapter {
  ProcessDialog adaptee;

  processDialog_processBtn_mouseAdapter(ProcessDialog adaptee) {
    this.adaptee = adaptee;
  }
  public void mouseClicked(MouseEvent e) {
    adaptee.processBtn_mouseClicked(e);
  }
}